<?php


/**
 * This is the model class for table "order_details".
 *
 * The followings are the available columns in table 'order':
 * @property integer $order_details
 * @property integer $customer_id
 * @property integer $quantity
 * @property integer $user_id Id of saler
 * @property integer $created_time
 * @property integer $price Retail price
 *
 */
class OrderDetail extends CActiveRecord
{

    /**
     * Returns the static model of the specified AR class.
     * @param string $className active record class name.
     * @return Order the static model class
     */
    public static function model($className = __CLASS__)
    {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName()
    {
        return 'order_details';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('order_id, item_id, user_id, created_time, quantity, price', 'numerical', 'integerOnly' => true),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('order_id, item_id, user_id, created_time, quantity, price', 'safe', 'on' => 'search'),
        );
    }


    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels()
    {
        return array(
            'order_id' 			=> '#',
            'item_id' 			=> 'Sản phẩm',
            'user_id' 			=> 'Nhân viên tư vấn',
            'created_time' 		=> 'Ngày bán',
            'quantity'			=> 'Số lượng',
            'price'				=> 'Giá bán'
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search()
    {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('order_id', $this->order_id, true);
		$criteria->compare('item_id', $this->item_id, true);
		$criteria->compare('user_id', $this->user_id, true);
		$criteria->compare('created_time', $this->created_time, true);
		$criteria->compare('price', $this->price, true);
		$criteria->compare('quantity', $this->quantity, true);

        return new CActiveDataProvider($this, array(
            'criteria' => $criteria,
        ));
    }
}
